# Maintainer: Rémi BERTHO <remi.bertho@openmailbox.org>

_realname=podofo
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.9.3
pkgrel=1
pkgdesc="A C++ library to work with the PDF file format (mingw-w64)"
arch=('any')
url="http://podofo.sourceforge.net"
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-fontconfig"
         "${MINGW_PACKAGE_PREFIX}-libtiff"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-lua"
         "${MINGW_PACKAGE_PREFIX}-openssl")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-cppunit")
source=("https://downloads.sourceforge.net/${_realname}/${_realname}-${pkgver}.tar.gz"
        "win.patch"
        "test.patch")
sha256sums=('ec261e31e89dce45b1a31be61e9c6bb250532e631a02d68ec5bb849ef0a222d8'
            '5f8483c87958a2912a404d3d9333fadee435ece92eb9d73834c37f5b825939d8'
            '7b01fcb94b9d82f1323440e771ecef2e740a993f90172801e290c3a271e745f1')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}/win.patch"
  patch -p1 -i "${srcdir}/test.patch"
}

build() {
  rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -Wno-dev \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DFREETYPE_INCLUDE_DIR=${MINGW_PREFIX}/include/freetype2 \
    -DCMAKE_BUILD_TYPE=Release \
    -DPODOFO_BUILD_SHARED=1 \
    -DPODOFO_HAVE_JPEG_LIB=1 \
    -DPODOFO_HAVE_PNG_LIB=1 \
    -DPODOFO_HAVE_TIFF_LIB=1 \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd build-${MINGW_CHOST}
  make DESTDIR=${pkgdir} install
}
